package org.prail.ui;

import java.io.File;

import javax.swing.JFileChooser;

public class DirectorySelector extends JFileChooser {
	private static final long serialVersionUID = 1612432309065704742L;
	private File current = null;

	public DirectorySelector(File current) {
		this.current = current;
		setCurrentDirectory(new java.io.File("."));
		setDialogTitle("Select directory");
		setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		setAcceptAllFileFilterUsed(false);
	}
	
	public File getDir() {
		if (showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
			return getSelectedFile();
		} else {
			return current;
		}
	}
}
